﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace TKToXML
{
    public class Common
    {
        public static void WriteFile(string fileName, string content)
        {
            StreamWriter writer = new StreamWriter(fileName);
            writer.Write(content);
            writer.Flush();
            writer.Close();
        }
    }

    public enum AgentStatus
    {
        DaiLyLamThuTucHQ = 1, UyThac = 2, NguoiKhai = 3, NguoiChiuTrachNhiemNopThue = 4, MaMID = 5
    }

    public enum MessageFuntion
    {
        Huy = 1, Sua = 5, KhaiBao = 8, ChuaXuLy = 12, HoiTrangThai = 13, DeNghi = 16, KhongChapNhan = 27,
        CapSoTiepNhan = 29, CapSoToKhai = 30, DuyetLuongChungTu = 31, ThongBaoThongQuan = 32, ThongBaoThucXuat = 33, ThongBaoGiamSat = 34
    }

    public enum MessageType
    {
        HopDong = 315, HoaDonThuongMai = 380, AirwayBill = 740,
        ImportableList = 501, ExportableList = 502, 
        CommercialImportDeclaration = 929, CommercialExportDeclaration = 930,
        EPZImportDeclaration = 933, EPZExportDelcaration = 934, ImportFromLocal = 937, ExportToDomestic = 938
    }

    public enum CommodityType
    {
        NguyenPhuLieu = 1,
        SanPham = 2,
        ThietBi = 3,
        HangMau = 4,
        PhePham = 5,
        TieuDung = 6,
        LoaiKhac = 7
    }

    public enum LoaiChungTu
    {
        ToKhai = 1,
        ChiTietHang = 2,
        TKTGPP1 = 11,
        TKTGPP2 = 12,
        TKTGPP3 = 13,
        TKTGPP4 = 14,
        TKTGPP5 = 15,
        TKTGPP6 = 16,
        HopDong = 20,
        HoaDon = 21,
        GiayPhep = 22,
        VanTaiDon = 23,
        GiayDangKyKiemTraChatLuong = 24,
        GiayThongBaoKetQuaKiemTraChatLuong = 25,
        GiayChungNhanXuatXuHangHoa = 26
    }

    public class Agent
    {
        public string Name;
        public string Identity;
        public int Status;

        public string ToXML()
        {
            string result = "";

            result += "<Agent>";
                result += "<name>" + Name + "</name>";
                result += "<identity>" + Identity + "</identity>";
                result += "<status>" + Status + "</status>";
            result += "</Agent>";

            return result;
        }
    }

    /// <summary>
    /// Thông tin về doanh nghiệp xuất nhập khẩu
    /// </summary>
    public class Importer
    {
        public string Name { get; set; }
        public string Identity { get; set; }

        public string ToXML()
        {
            string result = "";

            result += "<Impoter>";
                result += "<name>" + Name + "<name>";
                result += "<identity>" + Identity + "<identity>";                
            result += "</Impoter>";

            return result;
        }
    }

    /// <summary>
    /// Thông tin tham chiếu đến tờ khai
    /// </summary>
    public class DeclarationDocument
    {
        public int SoTK { get; set; }
        public DateTime NgayTK { get; set; }
        public string MaLH { get; set; }
        public string MaHQ { get; set; }

        public string ToXML()
        {
            string result = "";

            result += "<Impoter>";
                result += "<reference>" + SoTK.ToString() + "<reference>";
                result += "<issue>" + NgayTK.ToString("yyyy-MM-dd HH:mm:ss") + "<issue>";
                result += "<naturalOfTransaction>" + MaLH + "<naturalOfTransaction>";
                result += "<declarationOffice>" + MaHQ + "<declarationOffice>";
            result += "</Impoter>";

            return result;
        }
    }

    public class CurrencyExchange
    {
        /// <summary>
        /// Mã nguyên tệ
        /// </summary>
        public string CurrencyType;
        /// <summary>
        /// Tỷ giá nguyên tệ
        /// </summary>
        public decimal? Rate;

        public string ToXML()
        {
            return "<CurrencyExchange>" +
                        "<currencyType>" + CurrencyType + "</currencyType>" +
                        "<rate>" + Rate + "</rate>" +
                      "</CurrencyExchange>";
        }
    }

    public class ChiCucHaiQuan
    {
        public string Ma { get; set; }
        public string Ten { get; set; }

        public static List<ChiCucHaiQuan> ChiCucHaiQuans = new List<ChiCucHaiQuan>()
        {
            new ChiCucHaiQuan { Ma = "A01B01", Ten = "Chi Hai Quan San Bay quoc te Noi Bai" }
        };
    }  
  
    
}
